package com.jwgf.time;

import android.os.Bundle;
import android.os.Message;
import android.os.Messenger;
import android.os.RemoteException;

public class TimeManager {
	private Messenger send;
	private static TimeManager instance = new TimeManager();
	
	private TimeManager() {

	}

	public static void createInstance(Messenger sendMsger) {
		instance.send = sendMsger;
	}

	public static TimeManager getInstance() {
		if (instance.send != null) {
			return instance;
		} else {
			return null;
		}
	}
	
	public void setTime(long tick) {
		Message msg = Message.obtain();
		msg.what = TimeInterface.SET_TIME;
		Bundle bd = new Bundle();
		bd.putLong(TimeInterface.DATA, tick);
		msg.setData(bd);
		try {
			send.send(msg);
		} catch (RemoteException e) {
			e.printStackTrace();
		}
	}
}
